package Comprehensive_03;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        /*
            班级里有N个学生
            要求：
            被点到的学生不会再被点到
            如果班级中的学生点完了，则开启第二轮
         */

        ArrayList<String> list = new ArrayList<>();
        //添加数据
        Collections.addAll(list, "四糸乃", "时崎狂三", "溪弦", "五河琴里", "七罪", "十香", "小鸟游六花");
        //随机点名
        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入要操作的选项，1：开始点名，0：退出");
            switch (sc.next()) {
                case "1" -> {
                    int index = r.nextInt(list.size());
                    System.out.println(list.remove(index));
                    if (list.size() == 0){
                        Collections.addAll(list, "四糸乃", "时崎狂三", "溪弦", "五河琴里", "七罪", "十香", "小鸟游六花");
                    }
                }
                case "0" -> System.exit(0);
                default -> System.out.println("您输入的数字有误！！");
            }
        }
    }
}
